Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
✅ Deterministic PR hygiene checks passed. |
| try { | ||
| upstream.beforeDispatch?.(); | ||
| upstreamResponse = await fetch(url, { | ||
| upstreamResponse = await codexAccountFetch(codexLogAccountId(upstream.authContext), { config })(url, { |
There was a problem hiding this comment.
🟡 Local search proxy refusals can switch the active Codex account
When process NO_PROXY conflicts with a Pool account’s HTTP proxy, search records the local refusal as an upstream connection failure. Repeated unqualified searches can switch the active account even though no search reached ChatGPT.
Learn more
The ChatGPT search relay now uses codexAccountFetch for pool traffic. If process NO_PROXY exempts ChatGPT, configuredOutboundFetch rejects an explicitly selected HTTP proxy before opening a connection. The search error handler passes that refusal to the unqualified sidecar’s outcome recorder as connect_error. recordCodexUpstreamOutcome adds to the selected account’s transient failure streak and calls applyFailureFailover for an active account. With an eligible sibling, this updates the shared active selection rather than just returning a search error.
Example: With account A active, account B eligible, and the default threshold of three, three ordinary unqualified searches select A and hit the same local proxy refusal. The third failure can promote B, so fixing A’s proxy settings does not undo the account switch.
Recommended fix: Handle typed pre-send route refusals separately in handleSearch. Release the probe lease and return a local route error without recording an upstream outcome. Add a regression test for a valid HTTP proxy conflicting with process NO_PROXY that checks both zero sends and unchanged Pool health.
Was this helpful? React with 👍 or 👎 to provide feedback.
| try { | ||
| upstream.beforeDispatch?.(); | ||
| upstreamResponse = await fetch(url, { | ||
| upstreamResponse = await codexAccountFetch(codexLogAccountId(upstream.authContext), { config })(url, { |
There was a problem hiding this comment.
🟡 SOCKS5 searches fail before longer configured deadlines
Account-routed SOCKS5 searches inherit a 200-second idle timeout from socks5Fetch. A search that sends no headers during that interval returns 502 even when its configured deadline allows it to finish.
Learn more
The search handler creates an abort signal for the configured total deadline. Applying an account-specific SOCKS5 route makes configuredOutboundFetch use socks5Fetch, which also installs a fixed 200-second upstream socket idle timer. The search contract explains why a healthy request can send no response headers until the search finishes. If the socket timer fires first, it throws Socks5FetchError, not TimeoutError, and the search error handler returns 502 because the request deadline has not yet expired.
Example: With search.timeoutMs set to 240,000, a search that sends its first response headers 210 seconds after dispatch is cut off at 200 seconds when the selected account uses SOCKS5.
Recommended fix: Let this relay pass its upstream deadline policy through the account-aware transport, so the SOCKS5 response idle timer does not preempt the search budget. Keep the SOCKS5 connection and handshake guards and retain the fixed default for callers that do not supply a response budget.
Was this helpful? React with 👍 or 👎 to provide feedback.
| Search also resolves the selected Pool account's outbound route at its physical send boundary; | ||
| an account route overrides the OpenAI provider route, and an invalid route refuses the send. |
There was a problem hiding this comment.
🔍 Public proxy docs still exclude unqualified Pool search
Unqualified search now uses account-aware egress when it selects a Pool account. The provider configuration guide still says unqualified search has no provider route. Update it to distinguish Pool search from caller-owned search.
Was this helpful? React with 👍 or 👎 to provide feedback.
| globalThis.fetch = (async (_input: RequestInfo | URL, init?: RequestInit) => { | ||
| const headers = new Headers(init?.headers); | ||
| sends.push({ | ||
| proxy: (init as { proxy?: unknown } | undefined)?.proxy, | ||
| authorization: headers.get("authorization"), | ||
| account: headers.get("chatgpt-account-id"), | ||
| body: typeof init?.body === "string" ? JSON.parse(init.body) : undefined, | ||
| }); | ||
| return Response.json({ encrypted_output: "ciphertext", output: "search result" }); | ||
| }) as typeof fetch; |
There was a problem hiding this comment.
🔍 Search tests check the proxy option, not the network path
The stub confirms which proxy option search passes to fetch, not which route Bun uses. The PR reports no runtime checks. Run the focused search tests and use the loopback proxy tests as a model for verifying the physical route.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Closing this fork PR as superseded by lidge-jun#9129 at |
Search now uses the selected Codex account's configured outbound route.
Static Verification Checks
Selected Account Egress (Passed) — src/server/search.ts handleSearch passes the selected auth-context account into codexAccountFetch, establishing account-bound egress at the sink.
Route Precedence Fails Closed (Passed) — src/codex/account-egress-runtime.ts codexAccountRouting prioritizes account egress over provider routing and rejects missing pool bindings.
Malformed Route Refusal (Passed) — tests/server/server-search.test.ts asserts malformed selected routes return 502 without invoking the outbound fetch stub.
Qualified Relay Compatibility (Passed) — tests/server/server-search.test.ts asserts successful qualified search preserves credentials, account headers, and bare upstream model projection.
Direct Caller Compatibility (Passed) — src/codex/account-egress-runtime.ts codexAccountRouting leaves direct and main callers unchanged, preserving existing relay behavior.
Static Diff Integrity (Passed) — git diff --check reports no whitespace errors across all changed files, establishing final patch integrity.
Finding:
acf_b8f0e4ecf67276cb7603e32d7a0a3408Patch:
arp_32e8908c5a852b51870b3ad5bddba5dfBase commit:
5c827dc96b943b2d5433c6d74bfb1ecdc4b27502Patch SHA-256:
4fb302c0c04999c34462ae5c9ede2e78e325fbd3f0beb86cb753b437971925bd